|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jade.core.behaviours.Behaviour
|
+--jade.core.behaviours.CompositeBehaviour
|
+--jade.core.behaviours.FSMBehaviour
Composite behaviour with Finite State Machine based children scheduling.
It is a CompositeBehaviour that executes its children
behaviours according to a FSM defined by the user. More specifically
each child represents a state in the FSM.
The class provides methods to register states (sub-behaviours) and
transitions that defines how sub-behaviours will be scheduled.
At a minimum, the following steps are needed in order to properly
define a FSMBehaviour:
registerFirstState;
registerLastState;
registerState;
registerTransition;
registerDefaultTransition is also useful
in order to register a default transition from a state to another state
independently on the termination event of the source state.
SequentialBehaviour,
ParallelBehaviour, Serialized Form| Inner classes inherited from class jade.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
| Fields inherited from class jade.core.behaviours.CompositeBehaviour |
currentExecuted |
| Fields inherited from class jade.core.behaviours.Behaviour |
myAgent,
myEvent,
NOTIFY_DOWN,
NOTIFY_UP,
parent |
| Constructor Summary | |
FSMBehaviour()
Default constructor, does not set the owner agent. |
|
FSMBehaviour(Agent a)
This constructor sets the owner agent. |
|
| Method Summary | |
protected boolean |
checkTermination(boolean currentDone,
int currentResult)
Check whether this FSMBehaviour must terminate. |
protected Collection |
getChildren()
Return a Collection view of the children of this SequentialBehaviour |
protected Behaviour |
getCurrent()
Get the current child |
int |
getLastExitValue()
|
java.lang.String |
getName(Behaviour state)
|
Behaviour |
getState(java.lang.String name)
|
protected void |
handle(Behaviour.RunnableChangedEvent rce)
Handle block/restart notifications. |
int |
onEnd()
Override the onEnd() method to return the exit value of the last executed state. |
void |
registerDefaultTransition(java.lang.String s1,
java.lang.String s2)
Register a default transition in the FSM defining the policy for children scheduling of this FSMBehaviour. |
void |
registerFirstState(Behaviour state,
java.lang.String name)
Register a Behaviour as the initial state of this
FSMBehaviour. |
void |
registerLastState(Behaviour state,
java.lang.String name)
Register a Behaviour as a final state of this
FSMBehaviour. |
void |
registerState(Behaviour state,
java.lang.String name)
Register a Behaviour as a state of this
FSMBehaviour. |
void |
registerTransition(java.lang.String s1,
java.lang.String s2,
int event)
Register a transition in the FSM defining the policy for children scheduling of this FSMBehaviour. |
protected void |
scheduleFirst()
Prepare the first child for execution. |
protected void |
scheduleNext(boolean currentDone,
int currentResult)
This method schedules the next child to be executed. |
| Methods inherited from class jade.core.behaviours.CompositeBehaviour |
action,
block,
done,
onStart,
postAction,
preAction,
reset,
restart |
| Methods inherited from class jade.core.behaviours.Behaviour |
actionWrapper,
block,
getDataStore,
isRunnable,
root,
setAgent,
setDataStore |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public FSMBehaviour()
public FSMBehaviour(Agent a)
a - The agent this behaviour belongs to.| Method Detail |
public void registerState(Behaviour state,
java.lang.String name)
Behaviour as a state of this
FSMBehaviour. When the FSM reaches this state
the registered Behaviour will be executed.state - The Behaviour representing the statename - The name identifying the state.
public void registerFirstState(Behaviour state,
java.lang.String name)
Behaviour as the initial state of this
FSMBehaviour.state - The Behaviour representing the statename - The name identifying the state.
public void registerLastState(Behaviour state,
java.lang.String name)
Behaviour as a final state of this
FSMBehaviour. When the FSM reaches this state
the registered Behaviour will be executed and,
when completed, the FSMBehaviour will terminate too.state - The Behaviour representing the statename - The name identifying the state.
public void registerTransition(java.lang.String s1,
java.lang.String s2,
int event)
FSMBehaviour.s1 - The name of the state this transition starts froms2 - The name of the state this transition leads toevent - The termination event that fires this transition
as returned by the onEnd() method of the
Behaviour representing state s1.Behaviour.onEnd()
public void registerDefaultTransition(java.lang.String s1,
java.lang.String s2)
FSMBehaviour.
This transition will be fired when state s1 terminates with
an event that is not explicitly associated to any transition.s1 - The name of the state this transition starts froms2 - The name of the state this transition leads topublic Behaviour getState(java.lang.String name)
Behaviour representing the state whose
name is name.public java.lang.String getName(Behaviour state)
Behaviour
state.public int getLastExitValue()
public int onEnd()
Behaviour.onEnd()protected void scheduleFirst()
Behaviour registered as the first state of this
FSMBehaviourCompositeBehaviour.scheduleFirst()
protected void scheduleNext(boolean currentDone,
int currentResult)
currentDone - a flag indicating whether the just executed
child has completed or not.currentResult - the termination value (as returned by
onEnd()) of the just executed child in the case this
child has completed (otherwise this parameter is meaningless)CompositeBehaviour.scheduleNext(boolean, int)
protected boolean checkTermination(boolean currentDone,
int currentResult)
FSMBehaviour must terminate.CompositeBehaviour.checkTermination(boolean, int)protected Behaviour getCurrent()
CompositeBehaviour.getCurrent()protected Collection getChildren()
SequentialBehaviourCompositeBehaviour.getChildren()protected void handle(Behaviour.RunnableChangedEvent rce)
FSMBehaviour is blocked only when
its currently active child is blocked, and becomes ready again
when its current child is ready. This method takes care of the
various possibilities.rce - The event to handle.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||